import java.io.File;
import java.io.FileInputStream;

import org.apache.commons.io.FileUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class POIReadExcel
{

	public static void main(String[] args)
	{
		File file =new File("jxl_excel.xls");  //不能为xlsx格式
		try
		{
			//创建EXCEl
			FileInputStream stream = FileUtils.openInputStream(file);
			HSSFWorkbook workbook = new HSSFWorkbook(stream);
			
			//获取SHEET
			HSSFSheet sheet = workbook.getSheetAt(0);
			
			//获取每一行
			for(int i = 0 ; i < sheet.getLastRowNum();i++)
			{
				HSSFRow row = sheet.getRow(i);
				for(int j=0;j<row.getLastCellNum();j++)
				{
					HSSFCell cell = row.getCell(j);
					System.out.print(cell.getStringCellValue() + "  ");
				}
				System.out.println();
			}
			
			workbook.close();
			
		} catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		

	}

}
